library;

import 'package:flutter/material.dart';
import 'package:FlutterReader/page/search_page.dart';
import 'package:FlutterReader/wights/show_novel_test.dart';
import '/page/settings_page.dart';

import '../wights/LeftSlideInButton.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';

part './findSource/Source.dart';

class FindPage extends StatefulWidget {
  const FindPage({super.key});

  @override
  State<FindPage> createState() => _FindPageState();
}

class _FindPageState extends State<FindPage> with TickerProviderStateMixin<FindPage>{
  final _tabs = <String>["小说源1", "小说源2", "小说源3", "小说源4", "小说源5"];
  late final TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(
      vsync: this,
      length: _tabs.length,
      initialIndex: 0,
    );
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('发现',),
        actions: [
          LeftSlideInButton(
            myPageBuilder: (context) =>SearchPage(),
            icon: Icon(Icons.search),
          ),
          LeftSlideInButton(
            myPageBuilder: (context) => SettingsPage(),
            icon: Icon(Icons.settings),
          ),
        ],
        bottom: TabBar(
          controller: _tabController,

          tabAlignment: TabAlignment.center,

          // 标签的颜色
          // labelColor: Colors.blueAccent,
          // unselectedLabelColor: Colors.black,

          // 标签的文本样式
          labelStyle: const TextStyle(fontWeight: FontWeight.bold),
          unselectedLabelStyle: const TextStyle(fontWeight: FontWeight.normal),

          // 指示器的样式
          indicatorColor: Colors.blueAccent,
          indicatorSize: TabBarIndicatorSize.tab,

          // 不显示分割线
          dividerHeight: 0,

          // 去除点击效果
          overlayColor: WidgetStateProperty.all(Colors.transparent),

          // 创建标签页
          tabs: List.generate(
            _tabs.length,
            (index) => Tab(text: _tabs[index]),
          ),
        ),
      ),
      body: TabBarView(
      controller: _tabController,
      // children: List.generate(
      //   _tabs.length,
      //   (index) => Center(child: Text(_tabs[index],style: TextStyle(fontSize: 24),)),
      // ),
        children: [
          _buildSourcePage1(),
          _buildSourcePage2(),
          _buildSourcePage3(),
          _buildSourcePage4(),
          _buildSourcePage5(),
        ],
    ),
    );
  }
}


